package com.liduanwei.update.config;

import com.liduanwei.update.entity.AppInfo;

import java.io.FileInputStream;
import java.io.IOException;
import java.io.InputStream;
import java.util.Properties;

/**
 * Created by Wei on 17/10/3.
 */
public class AppInfoPropertiesReader {
    private static Properties properties = null;

    private static AppInfo appInfo;

    static {
        properties = new Properties();
        try {
            InputStream in = new FileInputStream("./self_version.properties");

            properties.load(in);
            appInfo = new AppInfo(getVersionCode(), getVersionName());
        } catch (IOException e) {
            e.printStackTrace();
        }
    }

    public static String getVersionName() {
        return properties.getProperty("version_name");
    }

    public static int getVersionCode() {
        return Integer.parseInt(properties.getProperty("version_code"));
    }

    public static AppInfo getAppInfo() {
        return appInfo;
    }


}
